#include "sina.h"
#include "oauth.h"
#include "parsexml.h"
#include <QDebug>
#include "weibodata.h"

Sina * Sina::m_instance = NULL;
QString Sina::myAccessToken = "myAccessToken";
QString Sina::myAccessTokenSecret = "myAccessTokenSecret";


Sina* Sina::getInstance()
{
    if(NULL == m_instance)
        m_instance = new Sina();
    return m_instance;
}
const QString Sina::DOMAIN_NAME = "http://api.t.sina.com.cn/";


const QString Sina::REQUEST_TOKEN = DOMAIN_NAME + "oauth/request_token";
const QString Sina::AUTHORIZE = DOMAIN_NAME + "oauth/authorize";
const QString Sina::ACCESS_TOKEN = DOMAIN_NAME + "oauth/access_token";

const QString Sina::USER_TIMELINE = DOMAIN_NAME + "statuses/user_timeline.xml";
const QString Sina::VERIFY_CREDENTIALS = DOMAIN_NAME + "account/verify_credentials.xml";
const QString Sina::FRIENDS_TIMELINE = DOMAIN_NAME+"statuses/friends_timeline.xml";
const QString Sina::MENTIONS = DOMAIN_NAME + "statuses/mentions.xml";
const QString Sina::COMMENTS_TIMELINE = DOMAIN_NAME + "statuses/comments_timeline.xml";
const QString Sina::COMMENTS_BY_ME = DOMAIN_NAME + "statuses/comments_by_me.xml";
const QString Sina::COMMENTS_TO_ME = DOMAIN_NAME + "statuses/comments_to_me.xml";
const QString Sina::COMMENTS = DOMAIN_NAME + "statuses/comments.xml";
const QString Sina::COUNTS = DOMAIN_NAME + "statuses/counts.xml";
const QString Sina::REPOST_TIMELINE = DOMAIN_NAME + "statuses/repost_timeline.xml";
const QString Sina::REPOST_BY_ME = DOMAIN_NAME + "statuses/repost_by_me.xml";
const QString Sina::UNREAD = DOMAIN_NAME + "statuses/unread.xml";
const QString Sina::RESET_COUNT = DOMAIN_NAME + "statuses/reset_count.xml";
const QString Sina::EMOTIONS = DOMAIN_NAME +"emotions.xml";
const QString Sina::SHOW_ID = DOMAIN_NAME + "statuses/show/: id.xml";
const QString Sina::USER_STATUSES_ID = DOMAIN_NAME + ":userid/statuses/:id.xml";
const QString Sina::UPDATE = DOMAIN_NAME + "statuses/update.xml";
const QString Sina::UPLOAD = DOMAIN_NAME + "statuses/upload.xml";
const QString Sina::DESTROY = DOMAIN_NAME + "statuses/destroy/:id.xml";
const QString Sina::REPOST = DOMAIN_NAME + "statuses/repost.xml";
const QString Sina::COMMENT = DOMAIN_NAME + "statuses/comment.xml";
const QString Sina::COMMENT_DESTROY = DOMAIN_NAME + "statuses/comment_destroy/:id.xml";
const QString Sina::COMMENT_DESTROY_BATCH = DOMAIN_NAME + "statuses/comment/destroy_batch.xml";
const QString Sina::REPLY = DOMAIN_NAME + "statuses/reply.xml";
const QString Sina::USERS_SHOW = DOMAIN_NAME + "users/show.xml";
const QString Sina::FRIENDS = DOMAIN_NAME + "statuses/friends.xml";
const QString Sina::FOLLOWERS = DOMAIN_NAME + "statuses/followers.xml";
const QString Sina::UPDATE_REMARK = DOMAIN_NAME + "user/friends/update_remark.xml";
const QString Sina::SUGGESTIONS = DOMAIN_NAME + "users/suggestions.xml";
const QString Sina::USERS_HOT = DOMAIN_NAME + "users/hot.xml";
const QString Sina::DIRECT_MESSAGES = DOMAIN_NAME + "direct_messages.xml";
const QString Sina::SENT = DOMAIN_NAME + "direct_messages/sent.xml";
const QString Sina::NEW = DOMAIN_NAME + "direct_messages/new.xml";
const QString Sina::DESTROY_ID = DOMAIN_NAME + "direct_messages/destroy/:id.xml";
const QString Sina::DIRECT_MESSAGES_DESTROY_BATCH = DOMAIN_NAME + "direct_messages/destroy_batch.xml";
const QString Sina::FRIENDSHIPS_CREATE = DOMAIN_NAME + "friendships/create.xml";
const QString Sina::FRIENDSHIPS_DESTROY = DOMAIN_NAME + "friendships/destroy.xml";
const QString Sina::FRIENDSHIPS_EXISTS = DOMAIN_NAME + "friendships/exists.xml";
const QString Sina::FRIENDSHIPS_SHOW = DOMAIN_NAME + "friendships/show.xml";
const QString Sina::FRIENDS_IDS = DOMAIN_NAME + "friends/ids.xml";
const QString Sina::FOLLOWERS_IDS = DOMAIN_NAME + "followers/ids.xml";
const QString Sina::TRENDS = DOMAIN_NAME + "trends.xml";
const QString Sina::TRENDS_STATUSES = DOMAIN_NAME + "trends/statuses.xml";
const QString Sina::TRENDS_FOLLOW = DOMAIN_NAME + "trends/follow.xml";
const QString Sina::TRENDS_DESTROY = DOMAIN_NAME + "trends/destroy.xml";
const QString Sina::TRENDS_HOURLY = DOMAIN_NAME + "trends/hourly.xml";
const QString Sina::TRENDS_DAILY = DOMAIN_NAME + "trends/daily.xml";
const QString Sina::TRENDS_WEEKLY = DOMAIN_NAME + "trends/weekly.xml";
const QString Sina::UPDATE_PRIVACY = DOMAIN_NAME + "account/update_privacy.xml";
const QString Sina::GET_PRIVACY = DOMAIN_NAME + "account/get_privacy.xml";
const QString Sina::BLOCKS_CREATE = DOMAIN_NAME + "blocks/create.xml";
const QString Sina::BLOCKS_DESTROY = DOMAIN_NAME + "blocks/destroy.xml";
const QString Sina::BLOCKS_EXISTS = DOMAIN_NAME + "blocks/exists.xml";
const QString Sina::BLOCKS_BLOCKING = DOMAIN_NAME + "blocks/blocking.xml";
const QString Sina::BLOCKS_BLOCKING_IDS = DOMAIN_NAME + "blocks/blocking.xml";
const QString Sina::TAGS = DOMAIN_NAME + "tags.xml";
const QString Sina:: TAGS_CREATE = DOMAIN_NAME + "tags/create.xml";
const QString Sina::TAGS_DESTROY = DOMAIN_NAME + "tags/destroy.xml";
const QString Sina::TAGS_SUGGESTIONS = DOMAIN_NAME + "tags/suggestions.xml";
const QString Sina::TAGS_DESTROY_BATCH = DOMAIN_NAME + "tags/destroy_batch.xml";
const QString Sina::RATE_LIMIT_STATUS = DOMAIN_NAME + "account/rate_limit_status.xml";
const QString Sina::END_SESSION = DOMAIN_NAME + "account/end_session.xml";
const QString Sina::UPDATE_PROFILE_IMAGE = DOMAIN_NAME + "account/update_profile_image.xml";
const QString Sina::UPDATE_PROFILE = DOMAIN_NAME + "account/update_profile.xml";
const QString Sina::FAVOURITES = DOMAIN_NAME + "favourites.xml";
const QString Sina::FAVOURITES_CREATE = DOMAIN_NAME + "favourites/create.xml";
const QString Sina::FAVOURITES_DESTROY = DOMAIN_NAME + "favourites/destroy/:id.xml";
const QString Sina::FAVOURITES_DESTROY_BATCH = DOMAIN_NAME + "favourites/destroy_batch.xml";
const QString Sina::SUGGESTIONS_AT_USERS = DOMAIN_NAME + "search/suggestions/at_users.xml";

const int Sina::iVERIFY_CREDENTIALS = 2000;
const int Sina::iFRIENDS_TIMELINE = 2001;
const int Sina::iUSER_TIMELINE = 2002;
const int Sina::iMENTIONS = 2003;
const int Sina::iCOMMENTS_TIMELINE = 2004;
const int Sina::iCOMMENTS_BY_ME = 2005;
const int Sina::iCOMMENTS_TO_ME = 2006;
const int Sina::iCOMMENTS = 2007;
const int Sina::iCOUNTS = 2008;
const int Sina::iREPOST_TIMELINE = 2009;
const int Sina::iREPOST_BY_ME = 2010;
const int Sina::iUNREAD = 2011;
const int Sina::iRESET_COUNT = 2012;
const int Sina::iEMOTIONS =2013;
const int Sina::iSHOW_ID = 2014;
const int Sina::iUSER_STATUSES_ID = 2015;
const int Sina::iUPDATE = 2016;
const int Sina::iUPLOAD = 2017;
const int Sina::iDESTROY = 2018;
const int Sina::iREPOST = 2019;
const int Sina::iCOMMENT = 2020;
const int Sina::iCOMMENT_DESTROY = 2021;
const int Sina::iCOMMENT_DESTROY_BATCH = 2022;
const int Sina::iREPLY = 2023;
const int Sina::iUSERS_SHOW = 2024;
const int Sina::iFRIENDS = 2025;
const int Sina::iFOLLOWERS = 2026;
const int Sina::iUPDATE_REMARK = 2027;
const int Sina::iSUGGESTIONS = 2028;
const int Sina::iUSERS_HOT = 2029;
const int Sina::iDIRECT_MESSAGES = 2030;
const int Sina::iSENT = 2031;
const int Sina::iNEW = 2032;
const int Sina::iDESTROY_ID = 2033;
const int Sina::iDIRECT_MESSAGES_DESTROY_BATCH = 2034;
const int Sina::iFRIENDSHIPS_CREATE = 2035;
const int Sina::iFRIENDSHIPS_DESTROY = 2036;
const int Sina::iFRIENDSHIPS_EXISTS = 2037;
const int Sina::iFRIENDSHIPS_SHOW = 2038;
const int Sina::iFRIENDS_IDS = 2039;
const int Sina::iFOLLOWERS_IDS = 2040;
const int Sina::iTRENDS = 2041;
const int Sina::iTRENDS_DAILY = 2042;
const int Sina::iTRENDS_DESTROY = 2043;
const int Sina::iTRENDS_FOLLOW = 2044;
const int Sina::iTRENDS_HOURLY = 2045;
const int Sina::iTRENDS_STATUSES =2046;
const int Sina::iTRENDS_WEEKLY = 2047;
const int Sina::iUPDATE_PRIVACY = 2048;
const int Sina::iGET_PRIVACY = 2049;
const int Sina::iBLOCKS_CREATE = 2050;
const int Sina::iBLOCKS_DESTROY = 2051;
const int Sina::iBLOCKS_EXISTS = 2052;
const int Sina::iBLOCKS_BLOCKING = 2053;
const int Sina::iBLOCKS_BLOCKING_IDS = 2054;
const int Sina::iTAGS = 2055;
const int Sina::iTAGS_CREATE = 2056;
const int Sina::iTAGS_DESTROY =2057;
const int Sina::iTAGS_DESTROY_BATCH = 2058;
const int Sina::iTAGS_SUGGESTIONS = 2059;
const int Sina::iRATE_LIMIT_STATUS = 2060;
const int Sina::iUPDATE_PROFILE = 2061;
const int Sina::iFAVOURITES = 2062;
const int Sina::iFAVOURITES_CREATE = 2063;
const int Sina::iFAVOURITES_DESTROY = 2064;
const int Sina::iFAVOURITES_DESTROY_BATCH = 2065;
const int Sina::iSUGGESTIONS_AT_USERS = 2066;
const int Sina::iEND_SESSION = 2067;
const int Sina::iUPDATE_PROFILE_IMAGE = 2068;


QString Sina::Source = "966880929";
QString Sina::Secret = "763f318c8a21e3fed8ba93fa6f75cbdb";
Sina::Sina(QObject *parent):QObject(parent)
{

}

void Sina::verifyCredentials()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2000,oauth.getDataRequest(VERIFY_CREDENTIALS));
}

void Sina::friendsTimeline()
{
    qDebug()<<"friendsTimeline";
  OAuth oauth;
  Thread *thread = new Thread();
  connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
  connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
  thread->setGet(2001,oauth.getDataRequest(FRIENDS_TIMELINE));


}
void Sina::userTimeline()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2002,oauth.getDataRequest(USER_TIMELINE));
}
void Sina::mentions()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2003,oauth.getDataRequest(MENTIONS));
}
void Sina::commentsTimeline()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2004,oauth.getDataRequest(COMMENTS_TIMELINE));


}
void Sina::commentsByMe()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2005,oauth.getDataRequest(COMMENTS_BY_ME));
}
void Sina::commentsToMe()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2006,oauth.getDataRequest(COMMENTS_TO_ME));
}
void Sina::comments()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2007,oauth.getDataRequest(COMMENTS));
}
void Sina::counts()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2008,oauth.getDataRequest(COUNTS));
}
void Sina::repostTimeline()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2009,oauth.getDataRequest(REPOST_TIMELINE));
}
void Sina::repostByMe()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2010,oauth.getDataRequest(REPOST_BY_ME));
}
void Sina::unread()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2011,oauth.getDataRequest(UNREAD));
}
void Sina::resetCount()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2012,oauth.getDataRequest(RESET_COUNT),QByteArray());
}
void Sina::emotions()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2013,oauth.getDataRequest(EMOTIONS));
}
void Sina::showId()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2014,oauth.getDataRequest(SHOW_ID));
}
void Sina::userStatusesId()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2015,oauth.getDataRequest(USER_STATUSES_ID));
}
void Sina::update()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2016,oauth.getDataRequest(UPDATE),QByteArray());
}
void Sina::upload()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2017,oauth.getDataRequest(UPLOAD),QByteArray());
}
void Sina::destroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2018,oauth.getDataRequest(DESTROY),QByteArray());
}
void Sina::repost()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2019,oauth.getDataRequest(REPOST),QByteArray());
}
void Sina::comment()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2020,oauth.getDataRequest(COMMENT),QByteArray());
}
void Sina::commentDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2021,oauth.getDataRequest(COMMENT_DESTROY),QByteArray());
}
void Sina::commentDestroyBatch()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2022,oauth.getDataRequest(COMMENT_DESTROY_BATCH),QByteArray());
}
void Sina::reply()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2023,oauth.getDataRequest(REPLY),QByteArray());
}
void Sina::usersShow()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2024,oauth.getDataRequest(USERS_SHOW));
}
void Sina::friends()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2025,oauth.getDataRequest(FRIENDS));
}
void Sina::followers()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2026,oauth.getDataRequest(FOLLOWERS));
}
void Sina::updateRemark()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2027,oauth.getDataRequest(UPDATE_REMARK),QByteArray());
}
void Sina::suggestions()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2028,oauth.getDataRequest(SUGGESTIONS));
}
void Sina::usersHot()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2029,oauth.getDataRequest(USERS_HOT));
}
void Sina::directMessages()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2030,oauth.getDataRequest(DIRECT_MESSAGES));
}
void Sina::sent()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2031,oauth.getDataRequest(SENT));
}
void Sina::New()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2032,oauth.getDataRequest(NEW),QByteArray());
}
void Sina::destroyId()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2033,oauth.getDataRequest(DESTROY_ID),QByteArray());
}
void Sina::directMessagesDestroyBatch()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2034,oauth.getDataRequest(DIRECT_MESSAGES_DESTROY_BATCH),QByteArray());
}
void Sina::friendshipsCreate()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2035,oauth.getDataRequest(FRIENDSHIPS_CREATE),QByteArray());
}
void Sina::friendshipsDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2036,oauth.getDataRequest(FRIENDSHIPS_DESTROY),QByteArray());
}
void Sina::friendshipsExists()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2037,oauth.getDataRequest(FRIENDSHIPS_EXISTS));
}
void Sina::friendshipsShow()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2038,oauth.getDataRequest(FRIENDSHIPS_SHOW));
}
void Sina::friendsIds()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2039,oauth.getDataRequest(FRIENDS_IDS));
}
void Sina::followersIds()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2040,oauth.getDataRequest(FOLLOWERS_IDS));
}
void Sina::trends()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2041,oauth.getDataRequest(TRENDS));
}
void Sina::trendsDaily()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2042,oauth.getDataRequest(TRENDS_DAILY));
}
void Sina::trendsDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2043,oauth.getDataRequest(TRENDS_DESTROY));
}
void Sina::trendsFollow()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2044,oauth.getDataRequest(TRENDS_FOLLOW),QByteArray());
}
void Sina::trendsHourly()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2045,oauth.getDataRequest(TRENDS_HOURLY),QByteArray());
}
void Sina::trendsStatuses()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2046,oauth.getDataRequest(TRENDS_STATUSES));
}
void Sina::trendsWeekly()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2047,oauth.getDataRequest(TRENDS_WEEKLY));
}
void Sina::updatePrivacy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2048,oauth.getDataRequest(UPDATE_PRIVACY));
}
void Sina::getPrivacy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2049,oauth.getDataRequest(GET_PRIVACY));
}
void Sina::blocksCreate()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2050,oauth.getDataRequest(BLOCKS_CREATE),QByteArray());
}
void Sina::blocksDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2051,oauth.getDataRequest(BLOCKS_DESTROY),QByteArray());
}
void Sina::blocksExists()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2052,oauth.getDataRequest(BLOCKS_EXISTS));
}
void Sina::blocksBlocking()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2053,oauth.getDataRequest(BLOCKS_BLOCKING));
}
void Sina::blocksBlockingIds()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2054,oauth.getDataRequest(BLOCKS_BLOCKING_IDS));
}
void Sina::tags()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2055,oauth.getDataRequest(TAGS));
}
void Sina::tagsCreate()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2056,oauth.getDataRequest(TAGS_CREATE),QByteArray());
}
void Sina::tagsDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2057,oauth.getDataRequest(TAGS_DESTROY),QByteArray());
}
void Sina::tagsDestroyBatch()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2058,oauth.getDataRequest(TAGS_DESTROY_BATCH),QByteArray());
}
void Sina::tagsSuggestions()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2059,oauth.getDataRequest(TAGS_SUGGESTIONS));
}
void Sina::rateLimitStatus()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2060,oauth.getDataRequest(RATE_LIMIT_STATUS));
}
void Sina::updateProfile()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2061,oauth.getDataRequest(UPDATE_PROFILE),QByteArray());
}
void Sina::favourites()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2062,oauth.getDataRequest(FAVOURITES));
}
void Sina::favouritesCreate()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2063,oauth.getDataRequest(FAVOURITES_CREATE),QByteArray());
}
void Sina::favouritesDestroy()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2064,oauth.getDataRequest(FAVOURITES_DESTROY),QByteArray());
}
void Sina::favouritesDestroyBatch()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2065,oauth.getDataRequest(FAVOURITES_DESTROY_BATCH),QByteArray());
}
void Sina::suggestionsAtUsers()
{
    OAuth oauth;
    Thread *thread = new Thread();
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setGet(2066,oauth.getDataRequest(SUGGESTIONS_AT_USERS));
}
void Sina::endSession()
{
    OAuth oauth;
    Thread *thread = new Thread;
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2067,oauth.getDataRequest(END_SESSION),QByteArray());
}
void Sina::updateProfileImage()
{
    OAuth oauth;
    Thread *thread = new Thread;
    connect(thread,SIGNAL(readData(int,QString)),this,SLOT(getData(int,QString)));
    connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
    thread->setPost(2068,oauth.getDataRequest(UPDATE_PROFILE_IMAGE),QByteArray());
}

void Sina::startOAuth()
{
    OAuth *oauth = new OAuth();
    oauth->startAuthorization("316654669@qq.com","bieailulu");
    connect(oauth,SIGNAL(success()),this,SLOT(friendsTimeline()));
}


void Sina::getData(int type, QString str)
{
   qDebug()<<"the friendsTimeline is -----------------"<<str;
   //bool var = parseXml->parseResetCount(str);
   //Count count= parseXml->parseUnRead(str);
   QList<Status*> statusList = parseXml->parseFriendsTimeline(str);
   //User user = parseXml->parseUserShow(str);
   //IdList *ids = parseXml->parseFriendIds(str);
   qDebug()<<"the statusList.count() is"<<statusList.count();
   foreach(Status *status,statusList)
   {
       qDebug()<<"--------------------------------";
       /*qDebug()<<comment->m_sText;
       qDebug()<<comment->m_sCreatedAt;
       qDebug()<<comment->m_sSource;
       qDebug()<<comment->m_sBmiddlePic;
       qDebug()<<comment->m_user.m_sScreenName;
       qDebug()<<comment->m_user.m_sLocation;
       qDebug()<<comment->m_user.m_sDescription;
       qDebug()<<comment->m_user.m_sUrl;
       qDebug()<<comment->m_user.m_sDomain;
       qDebug()<<comment->m_user.m_sGender;
       qDebug()<<comment->m_user.m_iFollowersCount;
       qDebug()<<comment->m_user.m_iFriendsCount;
       qDebug()<<comment->m_user.m_iStatusCount;
       qDebug()<<comment->m_user.m_iFavouritesCount;
       qDebug()<<comment->m_user.m_sCreatedAt;
       qDebug()<<comment->m_user.m_status->m_sText;
       qDebug()<<comment->m_replyComment.m_sCreatedAt;
       qDebug()<<comment->m_replyComment.m_sText;
       qDebug()<<comment->m_replyComment.m_user.m_sScreenName;
       qDebug()<<comment->m_status->m_user.m_iFriendsCount;
       qDebug()<<comment->m_status->m_user.m_iFollowersCount;
       qDebug()<<comment->m_status->m_user.m_sScreenName;
       qDebug()<<comment->m_user.m_status->m_sText;
       qDebug()<<comment->m_status->m_retweetedStatus.m_sText;
        */
       /*qDebug()<<comment->m_retweetedStatus.m_sText;
       qDebug()<<comment->m_retweetedStatus.m_sBmiddlePic;
       qDebug()<<comment->m_retweetedStatus.m_user.m_sScreenName;
       */
       /*qDebug()<<count.m_iComments;
       qDebug()<<count.m_iFollowers;
       qDebug()<<count.m_iNewStatus;
       qDebug()<<count.m_iMentions;
       */
       qDebug()<<status->m_sCreatedAt;
       qDebug()<<status->m_sText;
       qDebug()<<status->m_sSource;
       qDebug()<<status->m_user.m_iFollowersCount;
       qDebug()<<status->m_user.m_iFriendsCount;
       qDebug()<<status->m_user.m_iStatusCount;
       qDebug()<<status->m_user.m_sScreenName;
       qDebug()<<status->m_user.m_sLocation;
       qDebug()<<status->m_user.m_sDescription;
       qDebug()<<status->m_user.m_sGender;
       qDebug()<<status->m_retweetedStatus.m_sText;
       qDebug()<<status->m_retweetedStatus.m_user.m_sScreenName;

      /*qDebug()<<emtion->m_bCommon;
       qDebug()<<emtion->m_sUrl;
       qDebug()<<emtion->m_sPhrase;
       */
       /*qDebug()<<user.m_sScreenName;
       qDebug()<<user.m_iFollowersCount;
       qDebug()<<user.m_iFriendsCount;
       */
       /*qDebug()<<message->m_sCreatedAt;
       qDebug()<<message->m_sText;
       qDebug()<<message->m_sSenderScreenName;
       qDebug()<<message->m_sRecipientScreenName; */
   }
   /*qDebug()<<count.m_iComments;
   qDebug()<<count.m_iFollowers;
   qDebug()<<count.m_iNewStatus;
   */
   //qDebug()<<ids->m_iNextCursor;
}
